<?php
class DB_MyResult {
	private $result;
	
	public function __construct($result){
		$this->result = $result;
	}
	
	public function FetchRow(){
		return mysql_fetch_row($this->result);
	}
	
	public function FetchAssoc(){
		return mysql_fetch_assoc($this->result);
	}
	
	public function FetchObject(){
		return mysql_fetch_object($this->result);
	}
	
	public function FetchAll($limit = null){
		if($limit === null){
			$limit = INF;
		}
		
		$array = array();
		$num_row = 0;
		while( ($linha = $this->FetchAssoc()) && ($num_row < $limit) ){
			$array[] = $linha;
			$num_row++;
		}
		return $array;
	}
	
	public function NumRows(){
		return mysql_num_rows($this->result);
	}
	
	public function getResult(){
		return mysql_result($this->result,0);
	}
	
	public function FreeResult(){
		mysql_free_result($this->result);
	}
}
?>